package cn.lutu.lutu.controller;

import cn.lutu.lutu.mapper.RoutesMapper;
import cn.lutu.lutu.pojo.dto.RouteDTO;
import cn.lutu.lutu.pojo.entity.Route;
import cn.lutu.lutu.pojo.vo.RouteVO;
import cn.lutu.lutu.response.ResultVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@Api(tags = "路线产品模块")
@RestController
@RequestMapping("/v1/routes/")
public class RouteController {
    @Autowired
    RoutesMapper routesMapper;

    @Autowired
    RoutesMapper mapper;
    @ApiOperation(value = "添加路线产品功能")
    @PostMapping ("add")
    public ResultVO insert(@RequestBody RouteDTO routeDTO){

    return ResultVO.ok();
    }
    @ApiOperation("修改路线产品功能")
    @PostMapping("update")
    public ResultVO update(@RequestBody RouteDTO routeDTO){
        Route route = new Route();
        BeanUtils.copyProperties(routeDTO,route);
        mapper.update(route);
        return ResultVO.ok();
    }
    @ApiOperation(value = "删除路线产品功能")
    @PostMapping("/{id}/delete")
    public ResultVO delete(@PathVariable  Long id){
        mapper.delete(id);
        return ResultVO.ok();
    }
    @ApiOperation(value = "查询路线产品功能")
    @GetMapping("/{id}/select")
    public List<RouteVO>select(@PathVariable Long id){

        return mapper.select(id);
    }
}
